﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Profile;
using Model;
using BLL;

public partial class CartPage : System.Web.UI.Page
{
    private static IList<CartItemInfo> cartItems;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            cartItems = Profile.ShoppingCart.GetAllCartItems().ToList();
            CartGrid.DataSource = cartItems;
            CartGrid.DataBind();
            
            
        }
    }

    protected void CartGrid_DeleteCommand(object source, DataGridCommandEventArgs e)
    {
        Profile.ShoppingCart.Remove(cartItems[e.Item.ItemIndex].ItemISBN);
        Profile.Save();
        cartItems = Profile.ShoppingCart.GetAllCartItems().ToList();
        CartGrid.DataSource = cartItems;
        CartGrid.DataBind();
        Response.Write("<script>alert('删除成功')</script>");
    }
    protected void SubmitOrder_Click(object sender, EventArgs e)
    {
        Page.Response.Redirect("~/OrderGenPage.aspx");
    }
}